<template>
  <div>
    <el-table :data="stragicetableData" border :header-cell-style="{ background: '#eef1f6' }">
      <el-table-column type="index" label="序号" width="50">
        </el-table-column>
        <el-table-column
          prop="date"
          label="日期"
          :formatter="dataFormat"
          sortable
        ></el-table-column>
        <el-table-column
          prop="strategy_name"
          label="策略名称"
          sortable
        ></el-table-column>
        <el-table-column
          prop="strategy_id"
          label="策略ID"
          sortable
        ></el-table-column>
        <el-table-column prop="type" label="类型" sortable></el-table-column>
        <el-table-column prop="name" label="品名" sortable></el-table-column>
        <el-table-column
          prop="achieve_profit_loss"
          label="实现盈亏"
          sortable
        ></el-table-column>
        <el-table-column
          prop="holding_profit_loss"
          label="持有盈亏"
          sortable
        ></el-table-column>
    </el-table>
   <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="searchData.page"
      :page-size="searchData.pageSize"
      layout="total, prev, pager, next"
      :total="searchData.totalPage"
    >
    </el-pagination>
  </div>
</template>
<script>
import { constrategyprofit } from '../../../../../api/url_lcc';
export default {
  //期初开账-策略期初盈亏
  name: "strategiceBeginProfitAndLoss",
  data() {
    return {
      stragicetableData: [],
      searchData: {
        page: 1, //当前页
        pageSize: 20,
        totalPage: 0,
        begin_flag:"1",
        date: "",
        strategy_name: "",
        strategy_id: "",
        // type: "",
        // achieve_profit_loss: "",
        // holding_profit_loss: "",

      },
    };
  },
  methods: {
     // 每页数
    handleSizeChange(val) {
      this.searchData.pageSize = val;
      this.searchData.page = 1;
      this.getstragedata();
    },
    // 当前页
    handleCurrentChange1(val) {
      this.searchData.page = val;
      this.getstragedata();
    },
    // 查询策略期初盈亏
      getstragedata(){
        this.searchData.page = 1;
        constrategyprofit(this.searchData).then(res => {
            // if (res.errcode == "1") {
              this.stragicetableData = []
              var data1 = res.result.results
              this.searchData.totalPage = res.result.count;
              this.stragicetableData = data1
             }).catch(err =>{
          this.$message.error(err.msg);
        });
      },
  },
  mounted() {
     this.getstragedata();
  }
};
</script>
